<?php
/***************************************************************
 * 删除订单
 * 
 ***************************************************************/
	$protectid="14"; 
	include("../protect.php");
	include_once("../../config.inc.php");	
	include_once(CFG_LIB_DIR.'mysqldb.inc.php');
  $objDB = new mysqldb();
	include_once(CFG_LIB_DIR.'generic.lib.php');
  $objBase = new clsBase();
   if ($_POST['SelectedID']){
		 $strID=$_POST['SelectedID'];
	 }else{
		 echo "<script language=\"javascript\">\n";
		 echo "alert(\"请选择要删除的记录\")\n";
		 echo "history.back()\n";
		 echo "</script>";
	}
	//查出订单号
	$SelSQL = "SELECT `OrderCode` from ".con_strPREFIX."buycar WHERE SndID in ($strID)";
	$arrSn = $objDB->getAll($SelSQL);
	$arrCode = array();
	for($i=0; $i < count($arrSn); $i++){
			$arrCode[] = $arrSn[$i]['OrderCode'];
	}
	$strCode=implode(",", $arrCode);
	//删除订单产品
  $DelList="delete from ".con_strPREFIX."buycar where SndID in ($strCode)";
  $OrderList = $objDB->query($DelList);
 //删除订单基本信息
  $DelOrder="delete from ".con_strPREFIX."buycar where SndID in ($strID)";
  $OrderRs = $objDB->query($DelOrder);

	if($DelOrder and $OrderList){
		$objBase->popup("删除成功");
	 }else{
		$objBase->popup("删除失败");
	 }
?>


